package com.ksd.modules.members.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ksd.common.annotation.ApiLog;
import com.ksd.common.controller.BaseController;
import com.ksd.common.core.result.R;
import com.ksd.common.po.BatchIdsPO;
import com.ksd.common.web.annotation.RepeatSubmit;
import com.ksd.modules.members.po.AdminUserVipBuySavePO;
import com.ksd.modules.members.po.AdminUserVipBuySearchPO;
import com.ksd.modules.members.service.IAdminUserVipBuyService;
import com.ksd.modules.members.vo.AdminUserVipBuyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 平台up主用户 前端控制器
 * </p>
 *
 * @author Auto Generator
 * @since 2023-08-15
 */
@RestController
public class AdminUserVipBuyController extends BaseController {


    @Autowired
    private IAdminUserVipBuyService adminUserVipBuysService;

    /**
     * 查询首页平台用户订单模板接口
     * @param adminMayUsersSearchPO
     * @return
     */
    @PostMapping("/users/vip/buy/list")
    public R<Page<AdminUserVipBuyVo>> findAdminUserVipBuys(@Validated @RequestBody AdminUserVipBuySearchPO adminMayUsersSearchPO){
        return R.data(adminUserVipBuysService.findAdminUserVipBuys(adminMayUsersSearchPO));
    }
    
    /**
     * 保存和更新
     * @param adminUserVipBuysSavePO
     * @return
     */
    @PostMapping("/users/vip/buy/saveupdate")
    @ApiLog("平台用户订单保存和更新")
    public R<AdminUserVipBuyVo> saveUpdateAdminUserVipBuys(@Validated @RequestBody AdminUserVipBuySavePO adminUserVipBuysSavePO){
        return R.data(adminUserVipBuysService.saveUpdateAdminUserVipBuy(adminUserVipBuysSavePO));
    }

    /**
     * 根据id查询平台用户订单模板
     * @param id
     * @return
     */
    @PostMapping("/users/vip/buy/get/{id}")
    public R<AdminUserVipBuyVo> getAdminUserVipBuysById(@PathVariable("id")Long id){
        return R.data(adminUserVipBuysService.getAdminUserVipBuyById(id));
    }

    /**
     * 【平台用户订单】- 批量物理删除
     *
     * @return
     */
    @PostMapping("/users/vip/buy/batch/remove")
    @ApiLog("【平台用户订单】- 批量物理删除")
    @RepeatSubmit
    public R<Boolean> batchRemovesAdminUserVipBuy(@RequestBody BatchIdsPO batchIdsPO) {
        return R.data(adminUserVipBuysService.batchRemovesAdminUserVipBuy(batchIdsPO));
    }

    /**
     * 【平台用户订单】- 根据ID恢复删除
     * @param id
     * @return
     */
    @PostMapping("/users/vip/buy/remove/{id}")
    @ApiLog("【平台用户订单】- 根据ID恢复删除")
    public R<Boolean> removeAdminUserVipBuyById(@PathVariable("id")Long id){
        return R.data(adminUserVipBuysService.removeAdminUserVipBuyById(id));
    }

    /**
     * 【平台用户订单】-【订单】- 绑定订单
     *
     * @return
     */
    @PostMapping("/users/vip/buy/userbind")
    @ApiLog("【平台用户订单】-【订单】- 绑定订单")
    @RepeatSubmit
    public R<Boolean> bindUserOrder(
            @RequestParam("uuid")String uuid,
            @RequestParam("opid") Long opid
    ) {
        return R.data(adminUserVipBuysService.bindUserOrder(uuid, opid));
    }
}
